python绘制多条不同x轴曲线 您所在的位置:网站首页 xy 曲线图示例 python绘制多条不同x轴曲线

python绘制多条不同x轴曲线

2024-07-13 07:00| 来源: 网络整理| 查看: 265

Matplotlib简介

Matplotlib是非常强大的python画图工具

Matplotlib可以画图线图、散点图、等高线图、条形图、柱形图、3D图形、图形动画等。

Matplotlib安装

pip3 install matplotlib#python3

双X轴的

可以理解为共享y轴

ax1=ax.twiny()

ax1=plt.twiny()

双Y轴的

可以理解为共享x轴

ax1=ax.twinx()

ax1=plt.twinx()

自动生成一个例子

x = np.arange(0., np.e, 0.01)

y1 = np.exp(-x)

y2 = np.log(x)

fig = plt.figure()

ax1 = fig.add_subplot(111)

ax1.plot(x, y1)

ax1.set_ylabel('Y values for exp(-x)')

ax1.set_title("Double Y axis")

ax2 = ax1.twinx() # this is the important function

ax2.plot(x, y2, 'r')

ax2.set_xlim([0, np.e])

ax2.set_ylabel('Y values for ln(x)')

ax2.set_xlabel('Same X for both exp(-x) and ln(x)')

plt.show()



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有